home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Scope / Scope Disk #010 (199x)(Scope PD)(US)[WB].zip / Scope Disk #010 (199x)(Scope PD)(US)[WB].adf / BlitLab3 / doblit.c < prev    next >
C/C++ Source or Header  |  1988-05-14  |  2KB  |  80 lines

  1. /*
  2.  *   This is the routine which actually does the hard blits.  We just get
  3.  *   the blitter, stuff the values, wait for it to finish, disown the
  4.  *   blitter, and get out of there.  In this special version, we also
  5.  *   turn off the display and time the blit, and write the time on the
  6.  *   screen when done.
  7.  */
  8. #include "structures.h"
  9. /*
  10.  *   External values we use.
  11.  */
  12. extern struct blitregs blitregs ;
  13. extern long gvals[] ;
  14. /*
  15.  *   This include file includes the defines for all the blitter functions.
  16.  *   It only allows use of the `blit' operations; for area fills or line
  17.  *   drawing, it will need to be extended.
  18.  *
  19.  *   Information gleaned from the Hardware Reference Manual.
  20.  */
  21. #define BLTADD (0xdff040L)
  22. /*
  23.  *   This structure contains everything we need to know.
  24.  *   Do not do a structure copy into this!  Instead, assign
  25.  *   each field.  The last field assigned must be bltsize; that
  26.  *   starts up the blitter.  Also note that all of these are
  27.  *   write only, and you can't read them.
  28.  */
  29. struct bltstruct {
  30.    short con0 ;
  31.    short con1 ;
  32.    short afwm ;
  33.    short alwm ;
  34.    short cpth, cptl, bpth, bptl, apth, aptl, dpth, dptl ;
  35.    short bltsize ;
  36.    short dmy1, dmy2, dmy3 ;
  37.    short cmod, bmod, amod, dmod ;
  38.    short dmy4, dmy5, dmy6, dmy7 ;
  39.    short cdat, bdat, adat ;
  40. } *blitter = BLTADD ;
  41. /*
  42.  *   The actual routine.  After we own the blitter, we need to wait for
  43.  *   it to finish.
  44.  */
  45. int doblit() {
  46.    int toreturn ;
  47.  
  48.    if (gvals[GDGSIM])
  49.       return(dosimblit()) ;
  50.    OwnBlitter() ;
  51.    WaitBlit() ;
  52.    blitter->con0 = blitregs.con0 ;
  53.    blitter->con1 = blitregs.con1 ;
  54.    blitter->afwm = blitregs.afwm ;
  55.    blitter->alwm = blitregs.alwm ;
  56.    blitter->apth = blitregs.pth[0] ;
  57.    blitter->bpth = blitregs.pth[1] ;
  58.    blitter->cpth = blitregs.pth[2] ;
  59.    blitter->dpth = blitregs.pth[3] ;
  60.    blitter->aptl = blitregs.ptl[0] ;
  61.    blitter->bptl = blitregs.ptl[1] ;
  62.    blitter->cptl = blitregs.ptl[2] ;
  63.    blitter->dptl = blitregs.ptl[3] ;
  64.    blitter->amod = blitregs.mod[0] ;
  65.    blitter->bmod = blitregs.mod[1] ;
  66.    blitter->cmod = blitregs.mod[2] ;
  67.    blitter->dmod = blitregs.mod[3] ;
  68.    blitter->adat = blitregs.dat[0] ;
  69.    blitter->bdat = blitregs.dat[1] ;
  70.    blitter->cdat = blitregs.dat[2] ;
  71. /*
  72.  *   Wham!  It is the following assignment that starts the blitter.
  73.  */
  74.    blitter->bltsize = blitregs.size ;
  75.    WaitBlit() ;
  76.    toreturn = custom.dmaconr ;
  77.    DisownBlitter() ;
  78.    return(toreturn & DMAF_BLTNZERO ? 1 : 0) ;
  79. }
  80.